package com.soccerlover9527.jadis.util;

import com.soccerlover9527.jadis.exception.JadisException;

/**
 * <p></p>
 *
 * @author soccerlover9527@gmail.com
 * @since 2023-08-08
 */
public class StringUtil {
    /**
     * trans string to long.
     *
     * @param str input string
     * @return long
     * @throws JadisException if cast failed
     */
    public static Long stringToLong(String str) {
        if (str.isBlank()) {
            throw new JadisException("empty string");
        }
        try {
            return Long.parseLong(str);
        } catch (Exception e) {
            throw new JadisException("chars are not a number");
        }
    }
}
